<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>秒转时间(天, 时, 分, 秒)</title>
</head>
<body>
<script>
    /*
    * 一分       60秒
    * 一小时     3600秒
    * 一天       86400秒
    * */
    let totalSecond = 120330;

    function convertTime(second) {
        let day = Math.floor(second / 86400);
        second %= 86400;
        let hours = Math.floor(second / 3600);
        second %= 3600;
        let minutes = Math.floor(second / 60);
        second %= 60;
        let seconds = Math.floor(second);
        return `${day}天${hours}时${minutes}分${seconds}秒`
    }

    console.log(convertTime(totalSecond));
</script>
</body>
</html>


